﻿using GpCommon.Helpers;
using GPSpeedView.GPHelpers;
using GPSpeedView.Models;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GPSpeedView
{
    /// <summary>
    /// leixing
    /// </summary>
    public class ConfigData
    {
        public const string LockGpsFilePath = "DataTxt//LockGpsData.txt";
        public const string MidFastGpsFilePath = "DataTxt//MidFastGpsData.txt";
        public const string AnalyseGpsFilePath = "DataTxt//AnalyseGpsData.txt";
        public const string ConfigDataFilePath = "DataTxt//Config.txt";

        public static TimeSpan GpStartTime = new TimeSpan(9, 30, 0);
        public static TimeSpan GpStopTime = new TimeSpan(15, 0, 0);
        public static TimeSpan GpMidStopTime = new TimeSpan(11, 30, 0);
        public static TimeSpan GpMidStartTime = new TimeSpan(13, 0, 0);


        // 标记隐藏股
        public static List<string> FlagGps = new List<string>();
        // 最大股价
        public static double MaxPrice = 35.0;
        // 最小市值
        public static double MinMarkValue = 0;
        // 最小涨速
        public static double MinACCER = 2;

        // 盘后记录股

        // 记录盘尾最小涨幅
        public static double MinMarkUpForLocal = 9.0;
        // 是否根据最小涨幅过滤
        public static bool IsMinMarkUpForLocalEnable = false;
        // 开始记录时刻
        public static TimeSpan GPStartRecordTime = new TimeSpan(9,35,0);
        // 结束记录时刻
        public static TimeSpan GPEndRecordTime = new TimeSpan(14, 40, 0);

        public static bool Show60GP = true;
        public static bool Show00GP = true;
        public static bool Show30GP = false;
        public static bool Show43GP = false;
        public static bool ShowSTGP = false;

        public static bool IsFilterGps = true;

        public static double MinMarkUpForMidFast = 5.0;

        public static bool IsBackgroundDataBufferEnable = false;

        public static bool IsFst1PlateMode = false;

        public static int MaxFlashGpCount = 80;

        private static List<string> m_LockGPs;
        /// <summary>
        /// 自选股集合
        /// </summary>
        public static List<string> LockGPs
        {
            get 
            {
                if(m_LockGPs == null)
                {
                    m_LockGPs = DataHelper.GetLockGPs();
                }
                return m_LockGPs; 
            }
        }

        private static Dictionary<string, List<MidFastTopGpEntity>> m_MidFastUpGPs;
        /// <summary>
        /// 盘中速涨盘股
        /// </summary>
        public static Dictionary<string, List<MidFastTopGpEntity>> MidFastUpGPs
        {
            get
            {
                if (m_MidFastUpGPs == null)
                {
                    m_MidFastUpGPs = DataHelper.GetMidFastUpGPs();
                }
                return m_MidFastUpGPs;
            }
        }

        private static Dictionary<string, List<string>> m_AnalyseGPs;
        /// <summary>
        /// 分析优选股
        /// </summary>
        public static Dictionary<string, List<string>> AnalyseGPs
        {
            get
            {
                if (m_AnalyseGPs == null)
                {
                    m_AnalyseGPs = DataHelper.GetAnalyseGPs();
                }
                return m_AnalyseGPs;
            }
        }

        #region 数据缓存
        /// <summary>
        /// 高机会股缓存数据
        /// </summary>
        public static List<ViewEntity> HighGpDataInfo = new List<ViewEntity>();
        /// <summary>
        /// 自选股缓存数据
        /// </summary>
        public static List<ViewEntity> LockGpDataInfo;

        public static Dictionary<string, List<double>> TotalGpSufferData = new Dictionary<string, List<double>>();
        /// <summary>
        /// 昨日涨停
        /// </summary>
        public static List<string> YestodayTopGps = new List<string>();

        private List<string> m_GoUpMostGPs;
        /// <summary>
        /// 均线上行股
        /// </summary>
        public List<string> GoUpMostGPs
        {
            get 
            {
                if(m_GoUpMostGPs == null)
                {
                    m_GoUpMostGPs = GpLocalDataHelper.GetValidGpCodes();
                }
                return m_GoUpMostGPs;
            }
            set 
            { 
                m_GoUpMostGPs = value;
            }
        }


        #endregion
    }

    public class GPEntity
    {
        public string Code { get; set; }

        public DateTime Time { get; set; }
    }
    public enum SortType
    {
        ACCER,
        ACCERInFive
    }
}
